<%@ Page Language="C#" MasterPageFile="~/Admin.master" AutoEventWireup="true" CodeFile="Roles.aspx.cs" Inherits="Users_Roles" Title="Untitled Page" %>
<%@ Import Namespace="Telerik.Web.UI" %>
<%@ Register Src="~/Users/Header.ascx" TagName="Header" TagPrefix="uc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="phActions" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="phSubMenu" Runat="Server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="phMain" Runat="Server">
    <uc1:Header ID="ucHeader" runat="server" />
    <div class="tabPage">
        <telerik:RadAjaxLoadingPanel ID="loading" runat="server" Height="50%"
                Width="50%" BackColor="#ACACAC" Transparency="10" MinDisplayTime="4" InitialDelayTime="0">
                <img style="margin-top: 150px;" alt="Loading..." src='<%= RadAjaxLoadingPanel.GetWebResourceUrl(Page, "Telerik.Web.UI.Skins.Default.Ajax.loading6.gif") %>' />
        </telerik:RadAjaxLoadingPanel>
        <telerik:RadGrid ID="gridRoles" runat="server" AutoGenerateColumns="False" DataSourceID="dsUserRoles" GridLines="None" AllowAutomaticDeletes="True" AllowAutomaticInserts="True" AllowAutomaticUpdates="True" AutoGenerateDeleteColumn="False" AutoGenerateEditColumn="False" Skin="Telerik" OnItemDataBound="gridRoles_ItemDataBound" OnInsertCommand="gridRoles_InsertCommand">
            <MasterTableView CommandItemDisplay="Bottom" DataSourceID="dsUserRoles" InsertItemDisplay="Bottom" DataKeyNames="Id,ConcurencyId">
                <RowIndicatorColumn Visible="False">
                    <HeaderStyle Width="20px" />
                </RowIndicatorColumn>
                <ExpandCollapseColumn Resizable="False" Visible="False">
                    <HeaderStyle Width="20px" />
                </ExpandCollapseColumn>
                <Columns>
                    <telerik:GridDropDownColumn DataField="RoleId" HeaderText="RoleName" ReadOnly="True"
                        SortExpression="RoleName" UniqueName="RoleName" DataSourceID="dsRoles" ListTextField="Name" ListValueField="Id" >
                    </telerik:GridDropDownColumn>
                    <telerik:GridCheckBoxColumn DataField="IsAdminRole" DataType="System.Boolean" HeaderText="IsAdminRole"
                        ReadOnly="True" SortExpression="IsAdminRole" UniqueName="IsAdminRole">
                    </telerik:GridCheckBoxColumn>
                    <telerik:GridDateTimeColumn DataField="Created" DataType="System.DateTime" HeaderText="Created"
                        ReadOnly="True" SortExpression="Created" UniqueName="Created">
                    </telerik:GridDateTimeColumn>
                    <telerik:GridDateTimeColumn DataField="Start" DataType="System.DateTime" HeaderText="Start"
                        SortExpression="Start" UniqueName="Start" PickerType="DateTimePicker">  
                    </telerik:GridDateTimeColumn>
                    <telerik:GridDateTimeColumn DataField="End" DataType="System.DateTime" HeaderText="End"
                        SortExpression="End" UniqueName="End" PickerType="DateTimePicker">
                    </telerik:GridDateTimeColumn>
                    <telerik:GridButtonColumn CommandName="Edit" UniqueName="Edit" Text="Edit"/>
                    <telerik:GridButtonColumn CommandName="Delete" UniqueName="Delete" Text="Delete" ConfirmText="Are you sure?"/>
                </Columns>
                <NoRecordsTemplate>
                    This user currently has no roles.
                </NoRecordsTemplate>
                <EditFormSettings EditFormType="Template">
                    <FormTemplate>
                        <ul class="form">
                            <li>
                                <asp:Label ID="lblRole" Text="Role" AssociatedControlID="ddlRole" runat="server" />
                                <asp:DropDownList ID="ddlRole" runat="server" DataSourceID="dsRoles" DataTextField="Name" DataValueField="Id" AppendDataBoundItems="true" >
                                    <asp:ListItem Text="" Value="0" />
                                </asp:DropDownList>
                                <asp:CompareValidator ControlToValidate="ddlRole" Operator="GreaterThan" ValueToCompare="0" ErrorMessage="* Required" Type="Integer" runat="server"/>
                            </li>
                            <li>
                                <asp:Label ID="lblStart" Text="Start" AssociatedControlID="txtStart" runat="server" />
                                <telerik:RadDateTimePicker ID="txtStart" runat="server" ToolTip="The Date Time this role runs from." Culture="English (United Kingdom)">
                                    <TimeView Culture="English (United Kingdom)" runat="server">
                                    </TimeView>
                                    <DateInput InvalidStyleDuration="100" runat="server">
                                    </DateInput>
                                </telerik:RadDateTimePicker>
                            </li>
                            <li>
                                <asp:Label ID="Label1" Text="End" AssociatedControlID="txtEnd" runat="server" />
                                <telerik:RadDateTimePicker ID="txtEnd" runat="server" ToolTip="The Date Time this role runs to." Culture="English (United Kingdom)" MinDate="<%# DateTime.Now %>" >
                                    <TimeView Culture="English (United Kingdom)" runat="server">
                                    </TimeView>
                                    <DateInput InvalidStyleDuration="100" runat="server">
                                    </DateInput>
                                </telerik:RadDateTimePicker>
                            </li>
                            <li>
                                <asp:Button ID="lnkUpdate" CommandName='<%#Container is GridEditFormInsertItem ? "PerformInsert" : "Update" %>' Text='<%#Container is GridEditFormInsertItem ? "Insert" : "Update" %>' runat="server" />
                                <asp:Button ID="lnkCancel" CommandName="Cancel" Text="Cancel" runat="server" />
                            </li>
                        </ul>
                        <br />
                    </FormTemplate>
                    <PopUpSettings ScrollBars="None" />
                </EditFormSettings>
            </MasterTableView>
        </telerik:RadGrid>
        <telerik:RadAjaxManager ID="ajaxManager" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="gridRoles">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="gridRoles" LoadingPanelID="loading" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        <acms:UserRolesDataSource ID="dsUserRoles" runat="server" EnablePaging="False" OnBeforeUpdating="dsUserRoles_BeforeUpdating" OnSelectData="dsUserRoles_SelectData">
        </acms:UserRolesDataSource>
        <acms:RolesDataSource ID="dsRoles" runat="server" OnSelectData="dsRoles_SelectData" />
    </div>    
</asp:Content>

